package clientrequest;

import clientcore.Constants;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
public class RequestToServer {
    protected short size = 0;
    protected DataOutputStream outToServer = null;


    public RequestToServer() {

    }

    public void send(short requestCode, Vector<Object> args) {

    }

    public void setOut(DataOutputStream sendServer) {
        this.outToServer = sendServer;
    }

    protected void writeShort(short val) {
        try {
            outToServer.writeShort(Short.reverseBytes(val));
        } catch (IOException ex) {
            System.out.println("IO Exception in class RequestToServer in method writeShort()"+ex.toString());
        }
    }

    protected void writeInt(int val) {
        try {
            outToServer.writeShort(Integer.reverseBytes(val));
        } catch (IOException ex) {
            System.out.println("IO Exception in class RequestToServer in method writeInt()"+ex.toString());
        }
    }

    protected void writeString(String val) {
        try {
            short length = (short)val.length();
            outToServer.writeShort(Short.reverseBytes(length));
            outToServer.writeBytes(val);
        } catch (IOException ex) {
            System.out.println("IO Exception in class RequestToServer in method writeString()"+ex.toString());
        }
    }

}


